//
//  BBMainBaseViewController.m
//  BabyThermometer
//
//  Created by CaiLei on 10/2/14.
//  Copyright (c) 2014 baohu. All rights reserved.
//

#import "BBMainBaseViewController.h"

@interface BBMainBaseViewController ()

@end

@implementation BBMainBaseViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    UIImageView *bgImageView = [[UIImageView alloc] initWithFrame:self.view.bounds];
    bgImageView.autoresizingMask =  UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
    bgImageView.contentMode = UIViewContentModeScaleAspectFill;
    bgImageView.image = [UIImage imageNamed:@"main_bg"];
    [self.view insertSubview:bgImageView atIndex:0];
    
    [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"navi_transparent"] forBarMetrics:UIBarMetricsDefault];
    self.navigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent;
    self.navigationController.navigationBar.clipsToBounds = YES;
}

- (UIButton *)leftNaviWithIconNamed:(NSString *)iconName {
    UIButton *naviLeftBtn = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 33, 44)];
    [naviLeftBtn setImage:[UIImage imageNamed:iconName] forState:UIControlStateNormal];
    UIBarButtonItem *leftItem = [[UIBarButtonItem alloc]initWithCustomView:naviLeftBtn];
    self.navigationItem.leftBarButtonItem = leftItem;
    return naviLeftBtn;
}

- (UIButton *)rightNaviWithIconNamed:(NSString *)iconName {
    UIButton *naviRightBtn = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 33, 44)];
    [naviRightBtn setImage:[UIImage imageNamed:iconName] forState:UIControlStateNormal];
    UIBarButtonItem *rightItem = [[UIBarButtonItem alloc] initWithCustomView:naviRightBtn];
    self.navigationItem.rightBarButtonItem = rightItem;
    return naviRightBtn;
}

- (void)setVcTitle:(NSString *)title {
    UILabel *naviTitleLabel = [[UILabel alloc] initWithFrame:CGRectMake(60, 0, 200, 44)];
    naviTitleLabel.textAlignment = NSTextAlignmentCenter;
    naviTitleLabel.font = [UIFont systemFontOfSize:19];
    naviTitleLabel.text = title;
    self.navigationItem.titleView = naviTitleLabel;
}

@end
